package net.sk.china.city.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.sk.china.city.controller.base.BaseController;
import net.sk.china.city.domain.dto.AjaxResult;
import net.sk.china.city.domain.ArActivityRecord;
import net.sk.china.city.service.IArActivityRecordService;
import net.sk.china.city.domain.dto.TableDataInfo;

/**
 * 活动记录Controller
 * 
 * @author ruoyi
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/system/record")
public class ArActivityRecordController extends BaseController
{
    @Autowired
    private IArActivityRecordService arActivityRecordService;

    /**
     * 查询活动记录列表
     */
    @PreAuthorize("hasAnyAuthority('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArActivityRecord arActivityRecord)
    {
        startPage();
        List<ArActivityRecord> list = arActivityRecordService.selectArActivityRecordList(arActivityRecord);
        return getDataTable(list);
    }

    /**
     * 导出活动记录列表
     */
    @PreAuthorize("hasAnyAuthority('system:record:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArActivityRecord arActivityRecord)
    {
        List<ArActivityRecord> list = arActivityRecordService.selectArActivityRecordList(arActivityRecord);
//        ExcelUtil<ArActivityRecord> util = new ExcelUtil<ArActivityRecord>(ArActivityRecord.class);
//        util.exportExcel(response, list, "活动记录数据");
    }

    /**
     * 获取活动记录详细信息
     */
    @PreAuthorize("hasAnyAuthority('system:record:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(arActivityRecordService.selectArActivityRecordByPkId(pkId));
    }

    /**
     * 新增活动记录
     */
    @PreAuthorize("hasAnyAuthority('system:record:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ArActivityRecord arActivityRecord)
    {
        return toAjax(arActivityRecordService.insertArActivityRecord(arActivityRecord));
    }

    /**
     * 修改活动记录
     */
    @PreAuthorize("hasAnyAuthority('system:record:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ArActivityRecord arActivityRecord)
    {
        return toAjax(arActivityRecordService.updateArActivityRecord(arActivityRecord));
    }

    /**
     * 删除活动记录
     */
    @PreAuthorize("hasAnyAuthority('system:record:remove')")
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(arActivityRecordService.deleteArActivityRecordByPkIds(pkIds));
    }
}
